import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
  fullscreenLoading: false,
  loginData: sessionStorage.GLOBAL_LOGIN_DATA ? JSON.parse(sessionStorage.GLOBAL_LOGIN_DATA) : {login: false}
}

const mutations = {
  updateLoadingStatus (state, fullscreenLoading) {
    state.fullscreenLoading = fullscreenLoading
  },
  updateloginData (state, loginData) {
    state.loginData = loginData
  }
}

const actions = {
  updateloginDataAction ({commit}, loginData) {
    commit('updateloginData', loginData)
    sessionStorage.setItem('GLOBAL_LOGIN_DATA', JSON.stringify(loginData))
  }
}

export default new Vuex.Store({
  state,
  mutations,
  actions
})
